import { onBeforeUnmount, onMounted, reactive } from "vue";

export default function () {
  let point = reactive({
    x: 0,
    y: 0,
  })

  function savePoint(event) {
    point.x = event.pageX
    point.y = event.pageY
  }

  // 页面挂载后执行
  onMounted(() => {
    window.addEventListener('click', savePoint)
  })
  // 卸载之前
  onBeforeUnmount(() => {
    window.removeEventListener('click', savePoint)
  })

  return point
}
